<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>黔南民族师范学院综合教育学分认定系统</title>

    <link rel="stylesheet" href="/jquery-easyui-1.3.5/themes/icon.css" />
    <link rel="stylesheet" href="/jquery-easyui-1.3.5/themes/default/easyui.css"/>

    <script type="text/javascript" src="/jquery-easyui-1.3.5/jquery.min.js"></script>
    <script type="text/javascript" src="/jquery-easyui-1.3.5/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/jquery-easyui-1.3.5/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" th:inline="none">
  		$(function(){
  			$('#dg').datagrid({
			    url:'/semester/queryAllSemesters',
			    striped:true,
			    idField:'id',
			   	fitColumn:true,
			    nowrap:true, 
			    pagination:true, 
			    pageSize:3,
			    pageList:[3,6,9],
			    toolbar: [{
						iconCls: 'icon-add',
						text:'添加学期',
						handler: function(){
							parent.$("#win").window({
								title:"添加学期信息",
								width:400,
								height:200,
								content:'<iframe src="/semester/save" frameborder="0" width="100%" height="100%">'
							});
						}
					},'-',{
						iconCls: 'icon-edit',
						text:'更新学期',
						handler: function(){
							var rows = $("#dg").datagrid("getSelections");
							if(rows.length != 1){
								$.messager.show({
									title:'错误提示',
									msg:'请选择一条记录',
									timeout:5000,
									showType:'slide'
								});	
							}else{
								parent.$("#win").window({
								title:"更新学期",
								width:400,
								height:200,
								content:'<iframe src="/semester/update" frameborder="0" width="100%" height="100%">'
							});
							}
						}
					},'-',{
                    iconCls: 'icon-remove',
                    text:'删除学期',
                    handler: function(){
                        var rows = $("#dg").datagrid("getSelections");
                        if(rows.length != 1){
                            $.messager.show({
                                title:'错误提示',
                                msg:'请选择一条记录',
                                timeout:5000,
                                showType:'slide'
                            });
                        }else{
                            $.messager.confirm('删除确认对话框', '是否要删除选中的记录?', function(r){
                                if (r){
                                    var ids = "";
                                    for(var i=0;i<rows.length;i++){
                                        ids+=rows[i].id + ",";
                                    }
                                    ids=ids.substring(0, ids.lastIndexOf(","));
                                    $.post("/semester/semesterDelete",{ids:ids},function(result){
                                        if(result=="ok"){
                                            $("#dg").datagrid("reload");
                                            $("#dg").datagrid("uncheckAll");
                                        }
                                    });
                                }
                            });
                        }
                    }
                }
				],
			    
			    columns:[[
			   		{field:'check',checkbox:true},
			     	{field:'id',title:'编号',width:50,align:'center'},
			        {field:'name',title:'学期名称',width:200,align:'center'}
			    ]]
			});  

  		});
  	</script>
  </head>
  
  <body>
  	<table id="dg"></table>  
  </body>
</html>
